import send_msg from '@feidao-factory/send-msg';
import { ICondition } from '../../interfaces';

/**
 * 调用javaDSD
 * @param action_id 系统参数action_id
 * @param session_id 系统参数session_id
 * @param spaceid 系统参数spaceid
 * @param systemid 当前项目systemid
 * @param refsystemid 当前项目refsystemid
 * @param modelid 模块id
 * @param condition 条件
 * @example javadsd(action_id, session_id, spaceid, systemid, refsystemid, modelid, condition);
 */
export default function javadsd<T>(action_id: string, session_id: string, spaceid: string, systemid: string, refsystemid: string, modelid: string, condition: ICondition) {
	if (!condition) {
		condition = {
			paging: {
				index: 1,
				size: 12
			},
			param: {},
			sort: {}
		} as any;
	}
	if (!condition.paging) {
		condition.paging = {
			index: 1,
			size: 12
		};
	}
	if (!condition.param) {
		condition.param = {} as any;
	}
	if (!condition.sort) {
		condition.sort = {};
	}
	const msg = {
		condition,
		modelid,
		refsystemid,
		spaceid,
		systemid
	};
	return send_msg<T>(action_id, session_id, 'dataservice.javadsd', msg);
}
